Public Class SystemInfoDemo


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Output(String.Format("User Login: {0}", SystemInformation.UserName))
        Output(String.Format("Domain: {0}", SystemInformation.UserDomainName))

        If (Not SystemInformation.Network) Then
            Output("NetWork not connect")
        Else
            Output("NetWork connected")
        End If

        Output(String.Format("Computer Name: {0}", SystemInformation.ComputerName))
        Output(String.Format("Boot Mode: {0}", SystemInformation.BootMode.ToString()))
        With SystemInformation.PowerStatus
            Output(String.Format("Power Status: {0}", .BatteryChargeStatus.ToString()))
            Output(String.Format("Battery life: {0}", .BatteryFullLifetime))
            Output(String.Format("Battery life %: {0}", .BatteryLifePercent))
            Output(String.Format("Battery remain: {0}", .BatteryLifeRemaining))
            Output(String.Format("Power line Status: {0}", .PowerLineStatus))
        End With

        Dim s As Size
        s = SystemInformation.WorkingArea.Size
        Output("Screen Size :")
        Output("Width: " + s.Width.ToString())
        Output("Height: " + s.Height.ToString())

        Dim p As PowerStatus = SystemInformation.PowerStatus
        Output("Power Status")
        Output(p.BatteryChargeStatus.ToString())
        Output(p.BatteryFullLifetime.ToString())
        Output(p.BatteryLifePercent.ToString())
        Output(p.BatteryLifeRemaining.ToString())
        Output(p.PowerLineStatus.ToString())

    End Sub
    Private Sub Output(ByVal s As String)
        TextBox1.AppendText(s & vbCrLf)
    End Sub

End Class
